package com.itheima.health.h5.controller;

import com.itheima.health.entity.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public Result exceptionHandle(Exception e) {
        e.printStackTrace();
        String message = e.getMessage();
        if (message.length() > 200) {
            return new Result(false, message.substring(0, 200) + "...");
        } else {
            return new Result(false, message);
        }

    }
}
